package route

import (
	"github.com/gin-gonic/gin"
	"fmt"
)

func InitRouter() *gin.Engine {
	router := gin.Default()
	router.Use(gin.Logger())
	router.Use(MiddleWare())
	{
		router.GET("/", MainApi)
		router.GET("/resource", GetAllResource)
		router.POST("/resource/all", Query)
	}
	return router
}

func MiddleWare() gin.HandlerFunc {
	return func(c *gin.Context) {
		fmt.Println("MiddleWare working.....")
		c.Header("Access-Control-Allow-Origin", "*")
		//c.Header("Content-Length","Access-Control-Allow-Origin")
		c.Next()
	}
}
